<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:shiro="http://shiro.apache.org/tags"
                template="/WEB-INF/templates/default.xhtml">
    <ui:define name="content">

        <h:messages id="messages_jsId"/>

        <h:form id="shipments_form">

            <h:panelGrid columns="5">
                <p:commandButton id="ownership_btn" value="Take Ownership" action="#{shipments.takeOwnership}" update="shipments_dt"/>
                <p:button value="Back" outcome="index?faces-redirect=true"/>
            </h:panelGrid>

            <p:dataTable id="shipments_dt" value="#{shipmentsList}" var="ship"
                         selectionMode="single" selection="#{shipments.selectedShipment}" rowKey="#{ship.id}">

                <f:facet name="header">
                    <h:outputText id="shipments_dth" value="Shipment List"/>
                </f:facet>
                <p:column headerText="Code">
                    <h:outputText value="#{ship.code}"/>
                </p:column>
                <p:column headerText="Address">
                    <h:outputText value="#{ship.address}"/>
                </p:column>
                <p:column headerText="Owner">
                    <h:outputText value="#{(ship.owner!=null)?ship.owner.lastName:'None'}"/>
                </p:column>
            </p:dataTable>

        </h:form>
    </ui:define>
</ui:composition>
